﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class XTJCoinJoinRoom : MonoBehaviour
{

    public GameObject CommonBtn;
    public GameObject LocalTyrantBtn;
    public GameObject ExtremeBtn;
    public GameObject HundredBtn;

    public List<UILabel> baseScore;
    public List<UILabel> limitScore;
    private void Awake()
    {
        UIEventListener.Get(CommonBtn).onClick = ButtonClick;
        UIEventListener.Get(LocalTyrantBtn).onClick = ButtonClick;
        UIEventListener.Get(ExtremeBtn).onClick = ButtonClick;
        UIEventListener.Get(HundredBtn).onClick = ButtonClick;
    }
    private void Start()
    {
        EginUser user = EginUser.Instance;
        for (int i = 0; i < 3; i++)
        {

            string str = user.ReturnRelCoinForBrief(user.xtjRoomList[i].BaseScore);
            //Debug.Log(str);
            baseScore[i].text = str;
            string str1 = user.ReturnRelCoinForBrief(user.xtjRoomList[i].EnterLimit);
            //Debug.Log(str1);
            limitScore[i].text = "准入:" + str1;
        }
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "CommonBtn")
        {
            SendCoinJoinRoom(0);
        }
        else if (button.name == "LocalTyrantBtn")
        {
            SendCoinJoinRoom(1);
        }
        else if (button.name == "ExtremeBtn")
        {
            SendCoinJoinRoom(2);
        }
        else if (button.name == "HundredBtn")
        {
            //百人场
            PaiEnterRoundRequest lg = new Pb.PaiEnterRoundRequest { RoundId = 0, RoundType = 4 };
            SocketManager socketManager = SocketManager.Instance;
            socketManager.SendProtobuf1(lg, MsgId.PaiEnterRoundRequest);
        }
    }

    void SendCoinJoinRoom(int level)
    {
        Debug.Log(111);
        //小天九
        EginXTJ.Instance.level = level;
        PaiEnterRoundRequest lg = new Pb.PaiEnterRoundRequest();
        lg.RoundType = 4;
        lg.Level = level;
        Debug.LogError("--RoundType=" + lg.RoundType + "---level=" + lg.Level);
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendProtobuf1(lg, MsgId.PaiEnterRoundRequest);
    }
}